<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Luat开源项目脚本lib</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>script_LuaTask lib</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>


<h2>Modules</h2>
<ul class="nowrap">
  <li><a href="../modules/aLiYun.html">aLiYun</a></li>
  <li><a href="../modules/aLiYunOta.html">aLiYunOta</a></li>
  <li><a href="../modules/agps.html">agps</a></li>
  <li><a href="../modules/clib.html">clib</a></li>
  <li><a href="../modules/common.html">common</a></li>
  <li><a href="../modules/console.html">console</a></li>
  <li><a href="../modules/errDump.html">errDump</a></li>
  <li><a href="../modules/gps.html">gps</a></li>
  <li><a href="../modules/gpsv2.html">gpsv2</a></li>
  <li><a href="../modules/http.html">http</a></li>
  <li><strong>httpv2</strong></li>
  <li><a href="../modules/lbsLoc.html">lbsLoc</a></li>
  <li><a href="../modules/led.html">led</a></li>
  <li><a href="../modules/link.html">link</a></li>
  <li><a href="../modules/log.html">log</a></li>
  <li><a href="../modules/misc.html">misc</a></li>
  <li><a href="../modules/mqtt.html">mqtt</a></li>
  <li><a href="../modules/net.html">net</a></li>
  <li><a href="../modules/netLed.html">netLed</a></li>
  <li><a href="../modules/ntp.html">ntp</a></li>
  <li><a href="../modules/nvm.html">nvm</a></li>
  <li><a href="../modules/patch.html">patch</a></li>
  <li><a href="../modules/pb.html">pb</a></li>
  <li><a href="../modules/pins.html">pins</a></li>
  <li><a href="../modules/pm.html">pm</a></li>
  <li><a href="../modules/powerKey.html">powerKey</a></li>
  <li><a href="../modules/ril.html">ril</a></li>
  <li><a href="../modules/sim.html">sim</a></li>
  <li><a href="../modules/sms.html">sms</a></li>
  <li><a href="../modules/socket.html">socket</a></li>
  <li><a href="../modules/sys.html">sys</a></li>
  <li><a href="../modules/update.html">update</a></li>
  <li><a href="../modules/utils.html">utils</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>httpv2</code></h1>
<p>模块功能：HTTP客户端</p>
<p></p>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: OpenLuat.com</li>
        <li><strong>Release</strong>: 2017.10.23</li>
        <li><strong>License</strong>: MIT</li>
        <li><strong>Author</strong>: 稀饭放姜</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#request">
    request (method, url, timeout, params, data, ctype, basic, headers, cert)
    </a></td>
	<td class="summary">HTTP客户端</td>
	</tr>
</table>

<br/>
<br/>


    <h2 class="section-header "><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "request"></a>
    <strong  style="color: red;">
    request (method, url, timeout, params, data, ctype, basic, headers, cert)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">HTTP客户端</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">method</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        <pre class="example">提交方式"GET" or "POST"</pre>
        </li>
        <li><span class="parameter">url</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        <pre class="example">HTTP请求超链接</pre>
        </li>
        <li><span class="parameter">timeout</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">超时时间</pre>
        </li>
        <li><span class="parameter">params</span>
        <pre class="example">table类型，请求发送的查询字符串，通常为键值对表</pre>
        </li>
        <li><span class="parameter">data</span>
        <pre class="example">table类型，正文提交的body,通常为键值对、json或文件对象类似的表</pre>
        </li>
        <li><span class="parameter">ctype</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">Content-Type的类型(可选1,2,3),默认1:"urlencode",2:"json",3:"octet-stream"</pre>
        </li>
        <li><span class="parameter">basic</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        <pre class="example">HTTP客户端的authorization basic验证的"username:password"</pre>
        </li>
        <li><span class="parameter">headers</span>
        <pre class="example">table类型,HTTP headers部分</pre>
        </li>
        <li><span class="parameter">cert</span>
        <pre class="example">table类型，此参数可选，默认值为： nil，ssl连接需要的证书配置，只有ssl参数为true时，才参数才有意义，cert格式如下：
 {
  caCert = "ca.crt", --CA证书文件(Base64编码 X.509格式)，如果存在此参数，则表示客户端会对服务器的证书进行校验；不存在则不校验
  clientCert = "client.crt", --客户端证书文件(Base64编码 X.509格式)，服务器对客户端的证书进行校验时会用到此参数
  clientKey = "client.key", --客户端私钥文件(Base64编码 X.509格式) clientPassword = "123456", --客户端证书文件密码[可选]
  }</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>
        <li>
        <pre class="example">string,table,string,正常返回response_code, response_header, response_body</pre></li>
        <li>
        <pre class="example">string,string,错误返回 response_code, error_message</pre></li>
    </ol>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example"><span class="keyword">local</span> c, h, b = httpv2.request(url, method, headers, body)</pre></il>
        <li><pre class="example"><span class="keyword">local</span> r, e  = httpv2.request(<span class="string">"http://wrong.url/ "</span>)</pre></il>
    </ul>

</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2019-10-22 16:00:46 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

